package com.iqiju.guagua.photo.wx.mini.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicResponseParameters;
import com.iqiju.guagua.photo.wx.mini.common.Results;
import com.iqiju.guagua.photo.wx.mini.service.WxPhotoService;
import com.iqiju.guagua.photo.wx.mini.vo.TemplateVO;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "模板接口")
@RequestMapping("/wx/photo/template")
public class PhotoTemplateController {

    @Autowired
    private WxPhotoService wxPhotoService;







    @ApiImplicitParams({
            @ApiImplicitParam(name = "wxMiniAppId",value = "微信小程序本地自定义id",required = true,dataType = "String",paramType = "path",example = "1192388834980298754")
    })
    @ApiResponses(value = {
            @ApiResponse(code = 0, message = "接口返回成功"),
            @ApiResponse(code = 100, message = "参数错误，检查参数是否合法"),
            @ApiResponse(code = 405, message = "token错误"),
            @ApiResponse(code = 401, message = "登录过期或者未登录"),
            @ApiResponse(code = 200, message = "接口返回未知错误，请联系开发人员调试"),
            @ApiResponse(code = 500, message = "接口返回未知错误，请联系开发人员调试")
    })
    @ApiOperationSupport(
            responses = @DynamicResponseParameters(properties = {
                    @DynamicParameter(value = "返回结果码",name = "state",dataTypeClass = Integer.class,example = "0",required = true),
                    @DynamicParameter(value = "返回提示信息",name = "message",dataTypeClass = String.class,example = "SUCCESS",required = true),
                    @DynamicParameter(value = "模板编号数组",name = "content",dataTypeClass = List.class),
                    @DynamicParameter(value = "时间戳",name = "time",dataTypeClass = Long.class,example = "1567425139000",required = true)
            })
    )
    @ApiOperation(value = "模板号查询", notes = "访问此接口，查询模板所有编号")
    @GetMapping("num/{wxMiniAppId}")
    public Results<List<Integer>> nums(@PathVariable String wxMiniAppId){
        log.info("访问模板号查询接口--------------------------------------------------");
        return wxPhotoService.nums(wxMiniAppId);

    }









    @ApiImplicitParams({
            @ApiImplicitParam(name = "wxMiniAppId",value = "微信小程序本地自定义id",required = true,dataType = "String",paramType = "path",example = "1192388834980298754"),
            @ApiImplicitParam(name = "num",value = "特效编号（如果有n个动效，可使用1,2...n等值）",required = true,dataType = "String",paramType = "path",example = "1")
    })
    @ApiResponses(value = {
            @ApiResponse(code = 0, message = "接口返回成功"),
            @ApiResponse(code = 100, message = "参数错误，检查参数是否合法"),
            @ApiResponse(code = 405, message = "token错误"),
            @ApiResponse(code = 401, message = "登录过期或者未登录"),
            @ApiResponse(code = 200, message = "接口返回未知错误，请联系开发人员调试"),
            @ApiResponse(code = 500, message = "接口返回未知错误，请联系开发人员调试")
    })
    @ApiOperation(value = "模板查询", notes = "访问此接口，查询模板所有数据")
    @GetMapping("{wxMiniAppId}/{num}")
    public Results<TemplateVO> template(@PathVariable String wxMiniAppId, @PathVariable String num){
        log.info("访问模板查询接口--------------------------------------------------");
        return wxPhotoService.template(wxMiniAppId,num);
    }


















    @ApiImplicitParams({
            @ApiImplicitParam(name = "userTemplateId",value = "用户相册id",required = true,dataType = "String",paramType = "path",example = "1192388834980298754"),
    })
    @ApiResponses(value = {
            @ApiResponse(code = 0, message = "接口返回成功"),
            @ApiResponse(code = 200, message = "接口返回未知错误，请联系开发人员调试"),
            @ApiResponse(code = 405, message = "token错误"),
            @ApiResponse(code = 401, message = "登录过期或者未登录"),
            @ApiResponse(code = 200, message = "接口返回未知错误，请联系开发人员调试"),
            @ApiResponse(code = 500, message = "接口返回未知错误，请联系开发人员调试")
    })
    @ApiOperation(value = "用户相册查询", notes = "访问此接口，查询用户自定义动效模板相册")
    @GetMapping("user/{userTemplateId}")
    public Results<TemplateVO> userPhotoTemplate(@PathVariable String userTemplateId){
        log.info("访问用户相册查询接口--------------------------------------------------");
        return wxPhotoService.userPhotoTemplate(userTemplateId);
    }

}
